//
//  MineChangeMiMaViewController.m
//  TEst
//
//  Created by   丛熠超 on 2017/4/12.
//  Copyright © 2017年 Tongcheng. All rights reserved.
//

#import "MineChangeMiMaViewController.h"
#import "MineGaiPasswordOperator.h"

@interface MineChangeMiMaViewController ()
@property (weak, nonatomic) IBOutlet UILabel *IDLB;
@property (weak, nonatomic) IBOutlet UITextField *OldMiMaTextField;
@property (weak, nonatomic) IBOutlet UITextField *NewMiMaTextFeild;
@property (weak, nonatomic) IBOutlet UITextField *AgainMiMatextFeild;
@property (weak, nonatomic) IBOutlet UIButton *FinishBtn;
@property (weak, nonatomic) IBOutlet UIView *OldView;
@property (weak, nonatomic) IBOutlet UIView *NewView;
@property (weak, nonatomic) IBOutlet UIView *SureBtn;
@property (weak, nonatomic) IBOutlet UILabel *IDLabel;

@end

@implementation MineChangeMiMaViewController

- (void)setupView
{
    self.IDLabel.text = self.config.userId;
    _OldView.layer.cornerRadius = 5.0;
    _OldView.layer.masksToBounds = YES;
    _NewView.layer.cornerRadius = 5.0;
    _NewView.layer.masksToBounds = YES;
    _SureBtn.layer.cornerRadius = 5.0;
    _SureBtn.layer.masksToBounds = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"修改密码";
    [self setupView];
        // Do any additional setup after loading the view from its nib.
}
- (IBAction)GetFInIsh:(UIButton *)sender {
    NSLog(@"%@,%@,%@",_OldMiMaTextField.text, _NewMiMaTextFeild.text, _AgainMiMatextFeild.text);
    if (_OldMiMaTextField.text.length == 0) {
        [self showToastMessage:@"原密码不能为空"];
    }else if (_NewMiMaTextFeild.text.length == 0){
        [self showToastMessage:@"新密码不能为空"];
    }else if (_AgainMiMatextFeild.text.length == 0){
        [self showToastMessage:@"确认密码不能为空"];
    }else if (![_NewMiMaTextFeild.text isEqualToString:_AgainMiMatextFeild.text]){
        [self showToastMessage:@"新密码和确认密码不一致"];
    }else{
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        dic[@"token"] = self.config.token;
        dic[@"user_id"] = self.config.userId;
        dic[@"User_pass"] = self.OldMiMaTextField.text;
        dic[@"New_pass"] = self.NewMiMaTextFeild.text;
        dic[@"New_pass_confirm"] = self.AgainMiMatextFeild.text;
        MineGaiPasswordOperator *operator = [[MineGaiPasswordOperator alloc] initWithParams:dic];
        [self.networkingManager asyncTaskOnVC:self operator:operator successBlock:^(BaseModel *baseModel) {
            if ([baseModel.code isEqualToString:@"1"]) {
                [self showToastMessage:baseModel.msg];
                [self.navigationController popViewControllerAnimated:YES];
            }
        } failBlock:^(BaseModel *baseModel) {
            
        }];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
